<?php

namespace App\Http\Requests\article;

use Illuminate\Foundation\Http\FormRequest;

class store extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required',
            'markdown' => 'required',
            'cover' => 'required',
            'tag_ids'=>'required',
            'category_id'=>'required',
        ];
    }

    /**
     * 获取被定义验证规则的错误消息
     *
     * @return array
     * @translator laravelacademy.org
     */
    public function messages(){
        return [
            'title.required' => '文章标题不能为空',
            'markdown.required'  => '文章内容不能为空',
            'cover.required'  => '文章封面不能为空',
            'category_id.required'  => '必须选择分类',
            'tag_ids.required'  => '至少选择一个标签',
        ];
    }
}
